/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.ufc.quixada.adrs.dao;

import br.ufc.quixada.adrs.dao.config.PostGresMapConfig;
import br.ufc.quixada.adrs.model.Rebanho;
import java.sql.SQLException;
import java.util.List;

/**
 *
 * @author fernando
 */
public class RebanhoDAO {

    public void insert(Rebanho rebanho) throws SQLException{
        rebanho.setId(getProxId());
        PostGresMapConfig.getSqlMapClient().insert("addRebanho", rebanho);
    }

    public void update(Rebanho rebanho) throws SQLException{
        throw new UnsupportedOperationException("Not yet implemented");
    }

    public void delete(Long id) throws SQLException{
        PostGresMapConfig.getSqlMapClient().delete("deleteRebanho",id);
    }

    public List<Rebanho> getByQuestionarioQuantitativoId(Integer id) throws SQLException{
        throw new UnsupportedOperationException("Not yet implemented");
    }

    public Rebanho getById(Integer id) throws SQLException{
        throw new UnsupportedOperationException("Not yet implemented");
    }

     public Long getProxId() throws SQLException {
        Long id = (Long) PostGresMapConfig.getSqlMapClient().queryForObject("getMaxIdRebanho");
        if (id == null) {
            id = 0L;
        }
        return id + 1L;
    }

}
